#ifndef __TCPCONNECTION_H_
#define __TCPCONNECTION_H_

#include "InetAddress.hpp"
#include "Socket.hpp"
#include "SocketIO.hpp"

//一个TCP连接的主要功能就是收发数据

namespace ln{

class TcpConnection{
public:
    TcpConnection(int);
    string receive();
    void send(const string & msg);
    bool isClosed() const;

    //打印五元组信息
    string toString() const;

private:
    InetAddress getLocalAddr();
    InetAddress getPeerAddr();

private:
    Socket      _sock;
    SocketIO    _socketIO;
    InetAddress _localAddr;
    InetAddress _peerAddr;
};

}//end of namespace ln

#endif

